import { resolve } from 'path'
import { defineConfig, externalizeDepsPlugin, bytecodePlugin } from 'electron-vite'
import vue from '@vitejs/plugin-vue'
const publicDir = resolve('resources')
const envDir = resolve('build')

export default defineConfig({
  main: {
    plugins: [externalizeDepsPlugin(), bytecodePlugin()]
  },
  preload: {
    plugins: [externalizeDepsPlugin(), bytecodePlugin()]
  },
  renderer: {
    publicDir,
    envDir,
    //环境变量前缀自定义，默认 VITE_
    envPrefix: 'RENDERER_',
    resolve: {
      alias: {
        '@renderer': resolve('src/renderer/src')
      }
    },
    server: {
      proxy: {
        '/mohu': {
          target: 'https://img.moehu.org',
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/mohu/, '')
        }
      }
    },
    plugins: [
      vue()
    ],
    css: {
      preprocessorOptions: {
        scss: {
          api: "modern",
          javascriptEnabled: true,
          additionalData: "@use '@renderer/styles/mixin.scss';@use '@renderer/styles/main.scss' as *;",
        }
      }
    }
  }
})
